package com.yuw.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yuw.bean.AdminInfoBean;
import com.yuw.utils.MyUtils;

/**
 * Servlet implementation class ajaxDemoAction
 */
@WebServlet("/AjaxDemoAction")
public class AjaxDemoAction extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * 进行ajax响应
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 接收数据
		AdminInfoBean adminB = MyUtils.convertFormData2Bean(request, AdminInfoBean.class);
		System.out.println("从客户端请求获取的用户名为："+adminB.getAdminname());
		
		// 响应客户单的请求
		PrintWriter pw = response.getWriter();
		pw.write("用户已存在");
		pw.flush();
		//pw.close();
	}

}
